package com.tupu.mapper.admin;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tupu.entity.admin.RelationBuildingInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RelationBuildingMapper extends BaseMapper<RelationBuildingInfo> {

    //根据关系构建表id 查询关系表id
    @Select("select relation_id from relation_building where id=#{id};")
    Long findRelationIdById(Long id);

    //根据实体标签id 开始、结束的标签  删除关系关联表
    @Delete("DELETE FROM relation_building where start_id = #{label_id} or end_id = #{label_id};")
    void deleteByLabelId(Long label_id);

    //根据node_id 查询关系关联表的一条数据
    @Select("select * from relation_building where node_id = #{node_id};")
    List<RelationBuildingInfo> findOneByNodeId(Long node_id);

    //根据关系 id删除关系关联表
    @Delete("DELETE FROM relation_building where relation_id = #{id};")
    void deleteByRelationId(Integer id);
}
